package CTRLayer;

import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;


public class CtrSupplier {

    public CtrSupplier() {

    }
    
    
    public ArrayList<Supplier> findAllSuppliers()
    {
      IFDBSupplier dbSupplier = new DBSupplier();
      ArrayList<Supplier> allSup = new ArrayList();
      allSup = dbSupplier.getAllSupplier(false);
      return allSup;
    }
    
    public Supplier findByName(String name)
    {
        IFDBSupplier dbSup = new DBSupplier();
        return dbSup.searchSupplierName(name, true);
    }

    
    public Supplier findById(int ID)
    {
        IFDBSupplier dbSup = new DBSupplier();
        return dbSup.searchSupplierOnID(ID, true);
    }
      
    
    public int updateSupplier(String name, String address, String country, int phoneNo, String email)
     {
          IFDBSupplier dbSup = new DBSupplier();
          Supplier sup = new Supplier();
          //sup.setSupplierID(SupplierID);
          sup.setName(name);
          sup.setAddress(address);
          sup.setCountry(country);
          sup.setPhoneNo(phoneNo);
          sup.setEmail(email);
          return  dbSup.updateSupplier(sup);

      }


    public int insertNewSupplier(int SupplierID, String name, String address, String country, int phoneNo, String email)
      {
          IFDBSupplier dbSup = new DBSupplier();
          Supplier sup = new Supplier();
          sup.setSupplierID(SupplierID);
          sup.setName(name);
          sup.setAddress(address);
          sup.setCountry(country);
          sup.setPhoneNo(phoneNo);
          sup.setEmail(email);
          return  dbSup.insertSupplier(sup);

      }
    

}